package cn.abyss.admin.exception;

import cn.abyss.admin.consts.AdminWebConstants;
import cn.abyss.admin.enums.BaseAdminWebExceptionEnum;
import cn.abyss.admin.enums.BaseAdminWebExceptionLevelEnum;
import cn.abyss.admin.enums.AdminWebExceptionEnum;

/**
 * Description:
 *
 * @author zhangsj
 * @date Created on 2020/12/15
 */
public class AdminWebException extends BaseException {
    private String exceptionCode;

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * 指定的模块异常
     *
     * @param e
     */
    public AdminWebException(String mcode, AdminWebExceptionEnum e) {
        super(AdminWebConstants.ADMIN_WEB, mcode, e.getCode(), e.getMessage());
        this.exceptionCode = e.getCode();
    }

    /**
     * 指定的模块异常(带异常级别)
     *
     * @param e
     */
    public AdminWebException(String mcode, AdminWebExceptionEnum e, BaseAdminWebExceptionLevelEnum level) {
        super(AdminWebConstants.ADMIN_WEB, mcode, e.getCode(), e.getMessage(), level);
        this.exceptionCode = e.getCode();
    }

    /**
     * 指定的模块异常-带堆栈信息
     *
     * @param e
     */
    public AdminWebException(String mcode, AdminWebExceptionEnum e, Throwable cause) {
        super(AdminWebConstants.ADMIN_WEB, mcode, e.getCode(), e.getMessage(), cause);
        this.exceptionCode = e.getCode();
    }

    /**
     * 指定的模块异常-带堆栈信息(带异常级别)
     *
     * @param e
     */
    public AdminWebException(String mcode, AdminWebExceptionEnum e, BaseAdminWebExceptionLevelEnum level, Throwable cause) {
        super(AdminWebConstants.ADMIN_WEB, mcode, e.getCode(), e.getMessage(), level, cause);
        this.exceptionCode = e.getCode();
    }

    /**
     * 指定的自定义异常
     *
     * @param error
     */
    public AdminWebException(String code, String error) {
        super(code, error);
        this.exceptionCode = code;
    }

    /**
     * 指定的自定义异常(带异常级别)
     *
     * @param error
     */
    public AdminWebException(String code, String error, BaseAdminWebExceptionLevelEnum level) {
        super(code, error, level);
        this.exceptionCode = code;
    }

    /**
     * 只抛出异常信息
     *
     * @param error
     */
    public AdminWebException(String error) {
        super(error);
    }

    /**
     * 公共异常
     *
     * @param e
     */
    public AdminWebException(BaseAdminWebExceptionEnum e) {
        super(e);
    }

    public String getExceptionCode(){
        return exceptionCode;
    }

}
